package chixing.day13.mycompareDemo;

public class Student implements MyCompare<Student>{

    private int stuNo;
    private String stuName;
    private long stuTelno;
    private String stuPersonId;

    public Student(){}
    public Student(int stuNo, String stuName, long stuTelno, String stuPersonId) {
        this.stuNo = stuNo;
        this.stuName = stuName;
        this.stuTelno = stuTelno;
        this.stuPersonId = stuPersonId;
    }
    /**
     * 比较两个对象的先后顺序
     * @param anotherObj 另一个要比较的对象
     * @return 若 当前对象this < 指定对象another 返回，负整数
     *         若 当前对象this > 指定对象another 返回，正整数
     *         若 当前对象this == 指定对象another 返回 0
     */
    @Override
    public int compare(Student anotherObj) {
        if (this==anotherObj)
            return 0;
        if (this.stuName.compareTo(anotherObj.stuName) != 0)
            return this.stuName.compareTo(anotherObj.stuName);
        if (this.stuTelno - anotherObj.stuTelno != 0)
            return (int)(this.stuTelno - anotherObj.stuTelno);
        if (this.stuPersonId.compareTo(anotherObj.stuPersonId) != 0)
            return this.stuPersonId.compareTo(anotherObj.stuPersonId);
        return this.stuNo - anotherObj.stuNo;
    }

    public int getStuNo() {
        return stuNo;
    }

    public void setStuNo(int stuNo) {
        this.stuNo = stuNo;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public long getStuTelno() {
        return stuTelno;
    }

    public void setStuTelno(long stuTelno) {
        this.stuTelno = stuTelno;
    }

    public String getStuPersonId() {
        return stuPersonId;
    }

    public void setStuPersonId(String stuPersonId) {
        this.stuPersonId = stuPersonId;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuNo=" + stuNo +
                ", stuName='" + stuName + '\'' +
                ", stuTelno=" + stuTelno +
                ", stuPersonId='" + stuPersonId + '\'' +
                '}';
    }



}
